package com.ljw;

import io.netty.util.concurrent.*;
import org.junit.Test;
import org.redisson.Redisson;
import org.redisson.api.RLock;
import org.redisson.api.RedissonClient;
import org.redisson.command.CommandSyncService;
import org.redisson.config.Config;
import org.redisson.config.ConfigSupport;
import org.redisson.config.SingleServerConfig;
import org.redisson.connection.ConnectionManager;

import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;

/**
 * @Author: lijunwei
 * @Time: 2019/12/5 11:10
 */
public class TestDemo {

    public static void main(String[] args) {
        Config config = new Config();
        SingleServerConfig singleServerConfig = config.useSingleServer();
        singleServerConfig.setAddress("redis://192.168.1.50:6379").setPassword("bizvane").setDatabase(0);
        RedissonClient redissonClient = Redisson.create(config);


        RLock lock = redissonClient.getLock("78787815");

        lock.lock();   //1000L,TimeUnit.SECONDS

        System.out.println("--------------------------------name1-------------------------------------");

        lock.unlock();
    }



    @Test
    public void test02() {
        Promise<Long> promise = ImmediateEventExecutor.INSTANCE.newPromise();
        boolean done = promise.isDone();

//        promise.setSuccess(111L);
        promise.setFailure(new Throwable());

        boolean done0 = promise.isDone();

        System.out.println(promise);
        FutureListener<Long> futureListener = new FutureListener<Long>() {
            @Override
            public void operationComplete(Future<Long> future) throws Exception {

                System.out.println("---12121212---" + future.isSuccess()+"--"+future.getNow());
            }
        };

        boolean done1 = promise.isDone();
        Promise<Long> longPromise = promise.addListener(futureListener);
        System.out.println("-----------787878787-------------");

    }



}
